﻿package mortal.game.view.task
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import baseEngine.modifiers.*;
    import com.gengine.core.frame.*;
    import com.gengine.debug.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.utils.*;
    import frEngine.render.layer.uiEffectLayer.*;
    import mortal.common.net.*;
    import mortal.common.sound.*;
    import mortal.component.gLinkText.*;
    import mortal.component.gconst.*;
    import mortal.game.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.model.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.ai.ais.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.guide.*;
    import mortal.game.view.task.data.*;
    import mortal.game.view.task.drama.*;
    import mortal.game.view.task.drama.operations.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class TaskController extends Controller
    {
        private var _trackForNew:TaskTrackForNewPlayer;
        private var _trackModule:TaskTrackModuleNew;
        private var _taskModule:TaskModule;
        private var _dramaSteper:TaskDramaOperator;
        private var _linkProcessor:TaskLinkProcessor;
        private var _dramaJump:TaskDramaJump;
        private var _dramaJumpCode:int;
        public var _tobeRefreshGuildTaskCode:int;
        private var _lastEffectTime:int;
        private var _stopAllDramaTime:int = -111111;
        private var _isStoping:Boolean = false;
        private var _timerId:int = -1;
        private var _stoped:Boolean = true;
        private var _lastTime:int;
        private var _tellTime:int;
        private var _flyLinkData:GLinkTextData;
        private var _lastIndex:int = -2;
        private var _removedGroup:int = -1;
        private var _removedTime:int = -1;

        public function TaskController()
        {
            this._linkProcessor = new TaskLinkProcessor();
            return;
        }// end function

        override public function get view() : IView
        {
            if (this._trackModule == null)
            {
                this._trackModule = new TaskTrackModuleNew();
            }
            return this._trackModule;
        }// end function

        public function get taskMoudle() : TaskModule
        {
            if (this._taskModule == null)
            {
                this._taskModule = new TaskModule();
            }
            return this._taskModule;
        }// end function

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.TaskShowHideModule, this.showHideTaskModuleHandler);
            Dispatcher.addEventListener(EventName.TaskShowHideTrack, this.showHideTrackHandler);
            Dispatcher.addEventListener(EventName.TaskShowHideTrackExceptBtn, this.showHideTrackExceptBtnHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetRecv, this.refreshTaskCanGetHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingListRecv, this.refreshTaskDoingHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskUpdate, this.taskUpdateHandler);
            Dispatcher.addEventListener(EventName.DailyCopyTimesChanged, this.copyEnterTimeChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.RoleLevelUpdate, this.levelUpHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingAdd, this.taskDoingAddHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskDoingDel, this.removeFromDoingHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetAdd, this.taskCanGetAddHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskCanGetDel, this.taskCanGetDelHandler);
            NetDispatcher.addCmdListener(ServerCommand.VipLevelUp, this.refreshTrackHandler);
            NetDispatcher.addCmdListener(ServerCommand.CopyEnterTimesUpdate, this.refreshTrackHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskGetSucess, this.taskGetSucessHandler);
            NetDispatcher.addCmdListener(ServerCommand.TaskSubmitSuccess, this.taskSubmitSucessHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateTaskExecuteNum, this.taskNumHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicDramaStepMsg, this.dramaStepHandler);
            Dispatcher.addEventListener(EventName.Task_DramaNextStep, this.dramaNextStepHandler);
            Dispatcher.addEventListener(EventName.Task_DramaStopAll, this.stopAllDramaHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicDramaStart, this.daramStartHandler);
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicDramaEnd, this.daramEndHandler);
            Dispatcher.addEventListener(EventName.TaskModuleTabChange, this.taskModuleTabChangeHandler);
            Dispatcher.addEventListener(EventName.TaskMoudleViewTaskInfo, this.viewTaskInfoHandler);
            Dispatcher.addEventListener(EventName.TaskGiveupTask, this.giveupTaskHandler);
            Dispatcher.addEventListener(EventName.TaskQuickComplete, this.quickCompleteHandler);
            Dispatcher.addEventListener(EventName.TaskQuickCompleteFinish, this.quickCompleteFinishHandler);
            Dispatcher.addEventListener(EventName.TaskQuickFinish, this.quickFinishHandler);
            Dispatcher.addEventListener(EventName.TaskAskNextStep, this.askNextStepHandler);
            Dispatcher.addEventListener(EventName.FlyBoot_GLinkText, this.linkTextFlyBootHandler);
            Dispatcher.addEventListener(EventName.TaskTraceTargetEvent, this.clickToTargetHandler);
            Dispatcher.addEventListener(EventName.StageResize, this.stagetResizeHandler);
            Dispatcher.addEventListener(EventName.Guide_TaskTrackArrow, this.taskTrackGuideArrowHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateTaskChapterInfo, this.chapterInfoHandler);
            return;
        }// end function

        private function chapterInfoHandler(param1:MessageBlock) : void
        {
            cache.task.chapterInfo = param1.messageBase as STaskChapter;
            if (this._trackForNew != null && !this._trackForNew.isHide)
            {
                this._trackForNew.updateChapterInfo(cache.task.chapterInfo);
            }
            return;
        }// end function

        private function checkAndShowTaskTrackNew() : void
        {
            var _loc_1:* = Cache.instance.task.getTaskForNewPlayer();
            if (_loc_1 != null && cache.role.roleInfo.level <= 30)
            {
                if (this._trackModule != null)
                {
                    this._trackModule.dispose(true);
                    this._trackModule = null;
                }
                if (this._trackForNew == null)
                {
                    this._trackForNew = UICompomentPool.getUICompoment(TaskTrackForNewPlayer);
                }
                this._trackForNew.show();
                this._trackForNew.taskInfo = _loc_1;
                this._trackForNew.sublines = cache.task.getTaskByGroupInTaskDoing(ETaskGroup._ETaskGroupBranch);
                this._trackForNew.updateLayout();
                this._trackForNew.showGuideFlyBoot();
            }
            else if (cache.task.hasMainLineTask())
            {
                if (this._trackModule == null)
                {
                    this._trackModule = UICompomentPool.getUICompoment(TaskTrackModuleNew);
                }
                this._trackModule.show();
                if (this._trackForNew != null)
                {
                    this._trackForNew.dispose(true);
                    this._trackForNew = null;
                }
            }
            return;
        }// end function

        private function taskTrackGuideArrowHandler(event:DataEvent) : void
        {
            var _loc_2:Array = null;
            var _loc_3:Boolean = false;
            var _loc_4:Boolean = false;
            var _loc_5:GLinkTextData = null;
            var _loc_6:Boolean = false;
            if (this._trackModule != null)
            {
                _loc_2 = event.data as Array;
                _loc_3 = Boolean(_loc_2[0]);
                if (_loc_3)
                {
                    _loc_4 = Boolean(_loc_2[4]);
                    _loc_5 = _loc_2[3];
                    _loc_6 = _loc_2[5] == null ? (false) : (_loc_2[5] as Boolean);
                    this._trackModule.showGuideArrow(int(_loc_2[1]), int(_loc_2[2]), _loc_5, _loc_4, _loc_6);
                }
                else
                {
                    this._trackModule.hideGuideArrow();
                }
            }
            return;
        }// end function

        private function taskNumHandler(param1:MessageBlock) : void
        {
            var _loc_2:* = param1.messageBase as SPublicDictIntInt;
            cache.task.updateGroupFinishCount(_loc_2.publicDictIntInt);
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskGroupCountChange));
            if (this._trackModule != null)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            return;
        }// end function

        private function showDramaJump() : void
        {
            if (this._dramaJump == null)
            {
                this._dramaJump = new TaskDramaJump();
            }
            this._dramaJump.show();
            return;
        }// end function

        private function hidePassDrama() : void
        {
            if (this._dramaJump == null)
            {
                return;
            }
            if (!this._dramaJump.isHide)
            {
                this._dramaJump.hide();
            }
            return;
        }// end function

        private function levelUpHandler(param1:Object) : void
        {
            this.refreshTaskCanGetHandler();
            this.refreshTaskDoingHandler();
            return;
        }// end function

        private function stagetResizeHandler(event:DataEvent) : void
        {
            if (this._dramaSteper != null)
            {
                this._dramaSteper.stageResizeHandler();
            }
            return;
        }// end function

        private function taskGetSucessHandler(param1:int) : void
        {
            var _loc_2:* = getTimer();
            if (_loc_2 - this._lastEffectTime <= 2000)
            {
                return;
            }
            this._lastEffectTime = _loc_2;
            SoundManager.instance.soundPlay(SoundTypeConst.AcceptTask);
            var _loc_3:* = EffectPlayerPool.instance.getEffectPlayer(GlobalStaticResUrl.TaskGet, Game.scene, UIEffectList.instance.getRenderListByUILayerID(UILayerIDs.TextID), false);
            _loc_3.y = 40;
            _loc_3.play(PlayMode.ANIMATION_STOP_MODE);
            return;
        }// end function

        private function taskSubmitSucessHandler(param1:int) : void
        {
            var _loc_2:* = getTimer();
            if (_loc_2 - this._lastEffectTime <= 2000)
            {
                return;
            }
            this._lastEffectTime = _loc_2;
            SoundManager.instance.soundPlay(SoundTypeConst.CompleteTask);
            var _loc_3:* = EffectPlayerPool.instance.getEffectPlayer(GlobalStaticResUrl.TaskFinish, Game.scene, UIEffectList.instance.getRenderListByUILayerID(UILayerIDs.TextID), false);
            _loc_3.y = 40;
            _loc_3.play(PlayMode.ANIMATION_STOP_MODE);
            return;
        }// end function

        private function daramEndHandler(param1:MessageBlock) : void
        {
            Log.error("剧情，收到EPublicCommand._ECmdPublicDramaEnd消息，结束剧情");
            TaskDramaOperator.unLockAll();
            cache.task.isDrama = false;
            this.hidePassDrama();
            this._stoped = true;
            return;
        }// end function

        public function daramStartHandler(param1:MessageBlock) : void
        {
            Log.error("剧情，收到EPublicCommand._ECmdPublicDramaStart消息，开始进行剧情");
            TaskDramaOperator.lockAll();
            AIManager.cancelAll();
            cache.task.isDrama = true;
            this.showDramaJump();
            this._stoped = false;
            return;
        }// end function

        public function stopAllDramaHandler(event:DataEvent) : void
        {
            if (this._dramaSteper == null)
            {
                return;
            }
            if (TaskDramaScreenMove.isTweening)
            {
                return;
            }
            if (!this._dramaSteper.isCurStopable())
            {
                return;
            }
            if (this._dramaSteper.lastStep != null)
            {
                this._dramaJumpCode = this._dramaSteper.lastStep.dramaCode;
            }
            this._stopAllDramaTime = FrameManager.flashFrame.getTime();
            this._isStoping = true;
            this._dramaSteper.resume(this.stopAllDramaTimeHandler);
            this.hidePassDrama();
            GameProxy.task.finishDramaStep(-1);
            this._stoped = true;
            if (this._timerId > 0)
            {
                clearTimeout(this._timerId);
            }
            this._timerId = setTimeout(this.stopAllDramaTimeOut, 3000);
            return;
        }// end function

        private function stopAllDramaTimeOut() : void
        {
            this._timerId = -1;
            if (!this._isStoping)
            {
                return;
            }
            if (!AIManager.isWorking)
            {
                GameController.guide.resumeToTask();
            }
            return;
        }// end function

        public function get isStopingAllDrama() : Boolean
        {
            if (this._isStoping)
            {
                if (FrameManager.flashFrame.getTime() - this._stopAllDramaTime < 3000)
                {
                    return true;
                }
            }
            return false;
        }// end function

        private function stopAllDramaTimeHandler() : void
        {
            this._isStoping = false;
            this._stopAllDramaTime = -111111;
            GameController.guide.resumeToTask();
            if (this._timerId > 0)
            {
                clearTimeout(this._timerId);
                this._timerId = -1;
            }
            return;
        }// end function

        private function dramaNextStepHandler(event:DataEvent) : void
        {
            if (this._stoped)
            {
                return;
            }
            var _loc_2:* = event.data as TTaskDrama;
            if (_loc_2 == null)
            {
                return;
            }
            if (_loc_2.dramaCode == this._dramaJumpCode)
            {
                return;
            }
            var _loc_3:* = getTimer();
            Log.error("code = " + _loc_2.dramaCode + ", step=" + _loc_2.step + ", 执行一共用了毫秒 = " + (_loc_3 - this._lastTime));
            this._lastTime = _loc_3;
            _loc_2 = TaskConfig.instance.getDrama(_loc_2.dramaCode, (_loc_2.step + 1));
            if (_loc_2 == null || _loc_2.type >= EStepType._EStepTypeBuffAdd)
            {
                GameProxy.task.finishDramaStep((_loc_2.step - 1));
                Log.error("前端告诉服务器完成了：code=" + _loc_2.dramaCode + ", step=" + (_loc_2.step - 1));
                this._tellTime = _loc_3;
            }
            else
            {
                if (this._dramaSteper == null)
                {
                    this._dramaSteper = new TaskDramaOperator();
                }
                Log.error("前端继续执行步骤：code=" + _loc_2.dramaCode + ", step=" + _loc_2.step);
                this._dramaSteper.operate(_loc_2);
            }
            return;
        }// end function

        public function get dramaOperator() : TaskDramaOperator
        {
            if (this._dramaSteper == null)
            {
                this._dramaSteper = new TaskDramaOperator();
            }
            return this._dramaSteper;
        }// end function

        private function dramaStepHandler(param1:MessageBlock) : void
        {
            if (this._stoped)
            {
                return;
            }
            var _loc_2:* = param1.messageBase as SDramaStepMsg;
            if (_loc_2 == null)
            {
                return;
            }
            if (_loc_2.dramaCode == 13009)
            {
                this.hidePassDrama();
            }
            if (this._dramaSteper == null)
            {
                this._dramaSteper = new TaskDramaOperator();
            }
            var _loc_3:* = TaskConfig.instance.getDrama(_loc_2.dramaCode, _loc_2.step);
            if (_loc_3 == null)
            {
                Alert.show("服务器发来的dramaCode=" + _loc_2.dramaCode + ", step=" + _loc_2.step + "， 找不到配置");
                return;
            }
            this._dramaSteper.operate(_loc_3);
            this._lastTime = getTimer();
            Log.error("服务器告诉前端执行步骤：code=" + _loc_2.dramaCode + ", step=" + _loc_2.step);
            if (this._tellTime > 0)
            {
                Log.error("上次告诉服务器执行完步骤，到现在一共使用了毫秒：" + (this._lastTime - this._tellTime));
            }
            return;
        }// end function

        private function quickCompleteHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as TaskInfo;
            if (_loc_2 == null)
            {
                return;
            }
            GameProxy.task.quickComplete(_loc_2.stask.code);
            return;
        }// end function

        private function quickCompleteFinishHandler(event:DataEvent) : void
        {
            var info:TaskInfo;
            var todayTime:int;
            var totalTime:int;
            var left:int;
            var evt:* = event;
            info = evt.data as TaskInfo;
            if (info == null)
            {
                return;
            }
            var group:* = info.stask.group;
            if (group == ETaskGroup._ETaskGroupLoop)
            {
                var closed:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.task.quickComplete(info.stask.code);
                }
                else if (param1 == Alert.CANCEL)
                {
                    GameProxy.task.quickComplete(info.stask.code, true);
                }
                return;
            }// end function
            ;
                todayTime = Cache.instance.task.getGroupFinishCount(group);
                totalTime = TaskRule.getGroupTotalTimes(group);
                left = totalTime - todayTime + 1;
                Alert.buttonWidth = 85;
                Alert.okLabel = Language.getString(21202);
                Alert.calcelLabel = Language.getStringByParam(21203, left * 5);
                Alert.showCloseBtn = true;
                Alert.show(Language.getStringByParam(21204, left), null, Alert.OK | Alert.CANCEL, null, closed);
                return;
            }
            GameProxy.task.quickComplete(info.stask.code);
            GameProxy.task.endTask(0, info.stask.code);
            return;
        }// end function

        private function quickFinishHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as TaskInfo;
            if (_loc_2 == null)
            {
                return;
            }
            GameProxy.task.endTask(0, _loc_2.stask.code);
            return;
        }// end function

        private function taskCanGetAddHandler(param1:Object) : void
        {
            this.checkAndShowTaskTrackNew();
            this.refreshTaskCanGetHandler(null);
            var _loc_2:* = cache.task.getTaskByGroupInTaskCanget(ETaskGroup._ETaskGroupMinning);
            if (_loc_2 != null && _loc_2.length > 0)
            {
                cache.mining.clearAskedForHelp();
            }
            return;
        }// end function

        private function taskCanGetDelHandler(param1:Object) : void
        {
            this.checkAndShowTaskTrackNew();
            var _loc_2:* = int(param1);
            if (this._trackModule != null)
            {
                this._trackModule.tasks.removeItem(_loc_2);
            }
            if (this._taskModule != null && !this._taskModule.isHide && this._taskModule.selectedIndex == 1)
            {
                this.taskModuleTabChangeHandler(null);
            }
            return;
        }// end function

        private function giveupTaskHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as TaskInfo;
            if (_loc_2 == null)
            {
                return;
            }
            GameProxy.task.cancelTask(_loc_2.stask.code);
            if (this._taskModule != null && !this._taskModule.isHide)
            {
                this._taskModule.updateDesc(null);
            }
            return;
        }// end function

        private function linkTextFlyBootHandler(event:DataEvent) : void
        {
            if (!FlyBootAI.checkCanFly())
            {
                return;
            }
            var _loc_2:* = event.data as GLinkTextData;
            if (GameController.taskImpl.checkInGuideDefensecopy(_loc_2))
            {
                return;
            }
            if (GameMapUtil.shouldUseAutoPathReplaceFlyBoot(_loc_2.mapId, _loc_2.x, _loc_2.y))
            {
                MsgManager.showRollTipsMsg(Language.getString(21205));
                this._linkProcessor.processClickTarget(_loc_2);
            }
            else
            {
                this._flyLinkData = _loc_2;
                GameController.guide.checkAndBuyFlyBoot(this.startFlyLink);
            }
            return;
        }// end function

        private function startFlyLink() : void
        {
            if (this._flyLinkData == null)
            {
                return;
            }
            this._linkProcessor.processFlyBootTarget(this._flyLinkData);
            return;
        }// end function

        private function clickToTargetHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as GLinkTextData;
            if (GameController.taskImpl.checkInGuideDefensecopy(_loc_2))
            {
                return;
            }
            if (_loc_2.type == GLinkTextData.fly)
            {
                GameController.taskImpl.guideTaskFly(_loc_2);
                return;
            }
            if (_loc_2.subType == GLinkTextData.subType_Challenge)
            {
                if (GameController.copy.challengeCopy.isViewShow)
                {
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChallengeCopyOpen, {floor:_loc_2.x, level:_loc_2.y}));
                return;
            }
            GuideEffect.isShowPath = true;
            this._linkProcessor.processClickTarget(_loc_2);
            return;
        }// end function

        private function askNextStepHandler(event:DataEvent) : void
        {
            var _loc_10:Array = null;
            var _loc_2:* = event.data as Array;
            if (_loc_2 == null)
            {
                return;
            }
            var _loc_3:* = _loc_2[0] as TaskInfo;
            if (_loc_3 == null)
            {
                return;
            }
            var _loc_4:* = _loc_3.stask.group;
            var _loc_5:* = _loc_2[1] as NPCInfo;
            var _loc_6:int = 0;
            var _loc_7:* = _loc_3.stask.code;
            if (_loc_5 != null)
            {
                _loc_6 = _loc_5.tnpc.code;
            }
            if (_loc_3.isCanget())
            {
                GameProxy.task.getTask(_loc_6, _loc_7, _loc_3.stask.getChoose);
            }
            else if (_loc_3.isDoing())
            {
                GameProxy.task.talkToNpc(_loc_6, _loc_7);
            }
            else if (_loc_3.isComplete())
            {
                if (_loc_3.isCanNotEnd())
                {
                    MsgManager.showRollTipsMsg(Language.getString(21206));
                }
                else
                {
                    GameProxy.task.endTask(_loc_6, _loc_7, _loc_3.stask.endChoose);
                }
            }
            else if (_loc_4 == ETaskGroup._ETaskGroupMinning || _loc_4 == ETaskGroup._ETaskGroupEscort)
            {
                if (_loc_3.isFail())
                {
                    GameProxy.task.endTask(_loc_3.stask.endNpc, _loc_3.stask.code, _loc_3.stask.endChoose);
                }
            }
            var _loc_8:* = cache.npc.getTTaskDialog(_loc_3);
            if (_loc_8 == null)
            {
                return;
            }
            var _loc_9:* = _loc_8.showStr;
            if (_loc_9 != null)
            {
                _loc_10 = _loc_9.split("#");
                MsgManager.showTaskTarget(_loc_10[0] as String, int(_loc_10[1]));
            }
            _loc_9 = _loc_8.poetry;
            if (_loc_9 != null)
            {
                MsgManager.showPlotMsg(_loc_9);
            }
            return;
        }// end function

        private function viewTaskInfoHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as TaskInfo;
            if (this._taskModule && !this._taskModule.isHide)
            {
                this._taskModule.updateDesc(_loc_2);
            }
            return;
        }// end function

        private function taskModuleTabChangeHandler(event:DataEvent) : void
        {
            var _loc_5:Array = null;
            if (this._taskModule == null || this._taskModule.isHide)
            {
                return;
            }
            var _loc_2:* = this._taskModule.selectedIndex;
            this._taskModule.resetList();
            this._lastIndex = _loc_2;
            var _loc_3:Array = [];
            var _loc_4:Array = [];
            if (_loc_2 == 0)
            {
                _loc_5 = cache.task.taskDoing;
            }
            else
            {
                _loc_5 = cache.task.getTaskCanGet();
            }
            cache.task.getCatogeryHeadDatas(_loc_5, _loc_3, _loc_4);
            this._taskModule.initHeads(_loc_3);
            if (_loc_3.length == 0)
            {
                this._taskModule.updateDesc(null);
            }
            var _loc_6:int = 0;
            while (_loc_6 < _loc_4.length)
            {
                
                this._taskModule.setDataProvider(_loc_6, _loc_4[_loc_6] as DataProvider);
                _loc_6++;
            }
            this._taskModule.expand(0);
            return;
        }// end function

        private function refreshTrackHandler(param1 = null) : void
        {
            if (this._trackModule != null && Game.isSceneInit() && getTimer() >= 5000)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            return;
        }// end function

        private function refreshTaskCanGetHandler(param1:Object = null) : void
        {
            this.checkAndShowTaskTrackNew();
            if (this._trackModule != null)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            if (this._taskModule != null && !this._taskModule.isHide && this._taskModule.selectedIndex == 1)
            {
                this.taskModuleTabChangeHandler(null);
            }
            var _loc_2:* = cache.task.getTaskByGroupInTaskCanget(ETaskGroup._ETaskGroupMinning)[0] as TaskInfo;
            if (_loc_2 != null)
            {
                GameProxy.task.getMiningAllTaskInfos(_loc_2.stask.code);
            }
            var _loc_3:* = cache.task.getTaskByGroupInTaskCanget(ETaskGroup._ETaskGroupMinning);
            if (_loc_3 != null && _loc_3.length > 0)
            {
                cache.mining.clearAskedForHelp();
            }
            return;
        }// end function

        private function refreshTaskDoingHandler(param1:Object = null) : void
        {
            this.checkAndShowTaskTrackNew();
            if (this._trackModule != null)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            if (this._taskModule != null && !this._taskModule.isHide && this._taskModule.selectedIndex == 0)
            {
                this.taskModuleTabChangeHandler(null);
            }
            return;
        }// end function

        public function isJuseFinishedGroup(param1:int) : Boolean
        {
            if (FrameManager.flashFrame.getTime() - this._removedTime >= 1000)
            {
                return false;
            }
            return param1 == this._removedGroup;
        }// end function

        private function removeFromDoingHandler(param1:Object) : void
        {
            this.checkAndShowTaskTrackNew();
            var _loc_2:* = param1 as TaskInfo;
            if (_loc_2 == null)
            {
                return;
            }
            this._removedGroup = _loc_2.stask.group;
            this._removedTime = FrameManager.flashFrame.getTime();
            if (this._trackModule != null)
            {
                this._trackModule.tasks.removeItem(_loc_2.stask.code);
            }
            if (this._taskModule != null && !this._taskModule.isHide && this._taskModule.selectedIndex == 0)
            {
                this.taskModuleTabChangeHandler(null);
            }
            return;
        }// end function

        private function taskDoingAddHandler(param1:Object) : void
        {
            var obj:* = param1;
            this.checkAndShowTaskTrackNew();
            var code:* = int(obj);
            var info:* = cache.task.getTaskByCode(code);
            if (info == null)
            {
                return;
            }
            if (info.stask.code == GameConst.TaskEnterGuildCode)
            {
                var nextFrame:* = function () : void
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildOpen));
                return;
            }// end function
            ;
                CallLater.setCallLater(nextFrame, 0.5);
            }
            if (info.stask.group == ETaskGroup._ETaskGroupEscort)
            {
                TaskUtil.linkTask(info);
                NetDispatcher.dispatchCmd(ServerCommand.EscortCopyGetEscortSucceed, null);
            }
            if (this._trackModule != null)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            if (this._taskModule != null && !this._taskModule.isHide && this._taskModule.selectedIndex == 0)
            {
                this.taskModuleTabChangeHandler(null);
            }
            var arr:* = GLinkTextDataParser.parseProcess(info.stask.processMap, info, true);
            if (arr.length != 1)
            {
                return;
            }
            if (arr[0].length != 1)
            {
                return;
            }
            var linkData:* = arr[0][0] as GLinkTextData;
            if (linkData != null && linkData.type == GLinkTextData.introduce)
            {
                if (!TaskIntroduce.instance.isHide)
                {
                    TaskIntroduce.instance.show();
                }
                TaskIntroduce.instance.showIntroduces(arr[0]);
            }
            return;
        }// end function

        private function copyEnterTimeChangeHandler(param1 = null) : void
        {
            if (this._trackModule != null)
            {
                this._trackModule.tasks.initList(cache.task.taskShouldShowInTrack);
            }
            return;
        }// end function

        private function taskUpdateHandler(param1:Object) : void
        {
            var _loc_3:SPlayerTaskUpdate = null;
            var _loc_4:TaskInfo = null;
            this.checkAndShowTaskTrackNew();
            var _loc_2:* = param1 as Array;
            if (this._trackModule != null)
            {
                for each (_loc_3 in _loc_2)
                {
                    
                    _loc_4 = cache.task.getTaskByCode(_loc_3.taskCode);
                    if (_loc_4 != null)
                    {
                        this._trackModule.tasks.updateItem(_loc_4, false);
                    }
                }
                this._trackModule.tasks.updateLayout();
            }
            if (this._taskModule != null && !this._taskModule.isHide)
            {
                _loc_4 = this._taskModule.getCurDescInfo();
                if (_loc_4 != null)
                {
                    _loc_4 = cache.task.getTaskByCode(_loc_4.stask.code);
                    this._taskModule.updateDesc(_loc_4);
                }
            }
            return;
        }// end function

        private function showHideTrackHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Boolean;
            if (this._trackModule != null)
            {
                this._trackModule.visible = _loc_2;
            }
            if (this._trackForNew != null)
            {
                this._trackForNew.visible = _loc_2;
            }
            return;
        }// end function

        private function showHideTrackExceptBtnHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Boolean;
            if (this._trackModule != null)
            {
                this._trackModule.hideTrackExceptBtn(!_loc_2);
            }
            if (this._trackForNew != null)
            {
                this._trackForNew.hideTrackExceptBtn(!_loc_2);
            }
            return;
        }// end function

        private function showHideTaskModuleHandler(event:DataEvent) : void
        {
            if (this._taskModule != null && !this._taskModule.isHide)
            {
                this._taskModule.hide();
            }
            else
            {
                if (this._taskModule == null)
                {
                    this._taskModule = new TaskModule();
                }
                this._taskModule.show();
            }
            return;
        }// end function

    }
}
